package com.sjd.web.controller.wxma;

import com.sjd.common.annotation.Log;
import com.sjd.common.core.controller.BaseController;
import com.sjd.common.core.page.TableDataInfo;
import com.sjd.common.enums.BusinessType;
import com.sjd.common.utils.poi.ExcelUtil;
import com.sjd.wx.domain.SjdMember;
import com.sjd.wx.service.WxUserService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 微信用户
 *
 * @author maple
 * @date 2019-03-25 15:39:39
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/member/wxma")
public class WxUserController extends BaseController {

    private final WxUserService wxUserService;
    /**
     * 分页查询
     *
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('member:wx:ma')")
    public TableDataInfo listMemberMa(SjdMember sjdMember) {
        startPage();
        List<SjdMember> list = wxUserService.selectSjdMemberList(sjdMember);
        return getDataTable(list);
    }
    /**
     * 导出会员信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:wx:ma:export')")
    @Log(title = "会员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SjdMember sjdMember)
    {
        List<SjdMember> list = wxUserService.selectSjdMemberList(sjdMember);
        ExcelUtil<SjdMember> util = new ExcelUtil<>(SjdMember.class);
        util.exportExcel(response, list, "会员信息数据");
    }
}
